﻿using System;
using Atomic.Common;
using Atomic.Db;
using Atomic.Permission.Entities;
using System.Collections.Generic;
using System.Linq.Expressions;
namespace Atomic.Permission
{
    public interface IForm : IError
    {
        /// <summary>
        /// 获取当前父节点的所有子节点
        /// </summary>
        /// <param name="parentId">父节点ID，顶级节点输入0</param>
        /// <returns>子节点列表</returns>
        List<FormEntity> GetChildren(int parentId);
        
        /// <summary>
        /// 添加新的窗体
        /// </summary>
        /// <param name="entity">新窗体</param>
        /// <returns>添加窗体是否成功</returns>
        bool Add(FormEntity entity);

        /// <summary>
        /// 条件查询系统配置的窗体
        /// </summary>
        /// <param name="pager">分页参数，获取系统所有窗体，填入null</param>
        /// <param name="predicate">查询条件</param>
        /// <returns>分页的窗体结果</returns>
        Pager<FormEntity> GetPager(Pager pager, Expression<Func<FormEntity, bool>> predicate = null);
        
        /// <summary>
        /// 删除窗体
        /// </summary>
        /// <param name="id">主键ID</param>
        /// <returns>窗体删除是否成功</returns>
        bool Remove(int id);
        
        /// <summary>
        /// 更新窗体信息，不包括ChildrenCount
        /// </summary>
        /// <param name="entity">窗体信息</param>
        /// <param name="id">要更新窗体的主键</param>
        /// <returns>更新是否成功</returns>
        bool Update(FormEntity entity, int id);

        /// <summary>
        /// 查询资源基本信息
        /// </summary>
        /// <param name="id">资源ID</param>
        /// <returns>资源基本信息</returns>
        FormEntity Get(int id);
    }
}
